package com.course02.order_backend.exception.llh;

/*出错处理枚举，对应到桌号表，菜品表，订单表*/
public enum ErrorCode {
    /*针对桌号问题*/
    TABLE_NOT_EXIST(2001,"桌号不存在"),
    TABLE_ALREADY_OCCUPIED(2002,"桌号已被占用"),
    TABLE_STATUS_INVALLID(2003,"桌号状态异常，请联系管理员"),
    /*针对菜品表*/
    DISH_NOT_EXIST(3001,"菜品不存在"),
    DISH_STOCK_INSUFFICIENT(3002,"菜品库存不足"),
    DISH_OFF_SHELF(3003,"菜品已下架"),
    DISH_PRICE_INVALID(3004,"菜品价格异常，请联系管理员"),
    /*针对订单*/
    ORDER_CREATE_FAIL(4001,"订单创建失败"),
    ORDER_NOT_EXIST(4002,"订单不存在"),
    ORDER_STATUS_INVALID(4003,"订单状态异常，无法操作"),
    ORDER_DUPLICATE_KEY(4004,"订单提交冲突，请重试"),
    /*数据库通用错误*/
    DB_CONNECT_FAIL(5001,"系统连接数据库失败，请重试"),
    DB_OPERATE_TIMEOUT(5002,"系统请求超时，请重试"),
    /*系统问题*/
    SYSTEM_ERROR(9001,"系统异常，请联系管理员");

    private final int code;//错误编码
    private final String message;//错误描述
    private ErrorCode(int code,String message){//枚举不允许使用public
        this.code=code;
        this.message=message;
    }
    public int getCode(){
        return code;
    }
    public String getMessage(){
        return message;
    }


}
